package com.fz.service.merchant.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fz.common.ResponseEntity;
import com.fz.dto.merchant.merJob.MerJobAdd;
import com.fz.dto.merchant.merJob.MerJobQuery;
import com.fz.dto.merchant.merJob.MerJobUpd;
import com.fz.entity.merchant.MerJob;
import com.fz.mapper.merchant.MerJobMapper;
import com.fz.service.merchant.MerJobService;
import com.fz.vo.merchant.merJob.MerJobVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@SuppressWarnings("unchecked")
public class MerJobServiceImpl implements MerJobService {

    @Resource
    private MerJobMapper merJobMapper;

    /**
     * @方法描述:  查找岗位
     * @参数:
     * @返回值:
     * @创建人: shy
     * @创建时间:: 2021/3/17
     */
    @Override
    public ResponseEntity<IPage<MerJobVo>> findMerJobList(MerJobQuery merJobQuery, int pageNum, int pageSize) throws Exception {
        Page<MerJobVo> page = new Page<>(pageNum,pageSize);
        IPage<MerJobVo> JobQueryDataList = merJobMapper.findMerJobList(page,merJobQuery);
        return ResponseEntity.buildSuccess(JobQueryDataList);
    }

    /**
     * @方法描述:  增加岗位
     * @参数:
     * @返回值:
     * @创建人: shy
     * @创建时间:: 2021/3/17
     */
    @Override
    public ResponseEntity addMerJob(MerJobAdd merJobAdd) throws Exception {
        MerJob job = new MerJob();
        job.setName(merJobAdd.getName());
        job.setDeptId(merJobAdd.getDeptId());
        job.setSort(merJobAdd.getSort());
        job.setStatus(merJobAdd.getStatus());
        merJobMapper.insert(job);
        return ResponseEntity.buildSuccess();
    }

    /**
     * @方法描述:  更改岗位
     * @参数:
     * @返回值:
     * @创建人: shy
     * @创建时间:: 2021/3/17
     */
    @Override
    public ResponseEntity updateMerJob(MerJobUpd merJobUpd) throws Exception {
        MerJob job = new MerJob();
        job.setId(merJobUpd.getId());
        job.setName(merJobUpd.getName());
        job.setDeptId(merJobUpd.getDeptId());
        job.setSort(merJobUpd.getSort());
        job.setStatus(merJobUpd.getStatus());
        merJobMapper.updateById(job);
        return ResponseEntity.buildSuccess();
    }


}
